/**
 * 酒秀
 * 9elephas.com
 */
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Image,
} from 'react-native';

import React from 'react'
import { StackNavigator, TabNavigator , NavigationActions} from 'react-navigation'
import { COLOR } from './config'
import * as components from './components'


const login = StackNavigator(
  {
    PreLogin: { screen: components.PreLogin },
    // Login: { screen: components.Login },

    ResePassWord: { screen: components.ResePassWord },
    Protocol: { screen: components.Protocol },
    // RegisterMobile: { screen: components.RegisterMobile },
    // RegisterVerify: { screen: components.RegisterVerify },
    // RegisterProfile: { screen: components.RegisterProfile }
  },
  {
    navigationOptions: {
      headerTintColor: COLOR.textLightNormal,
      headerStyle: { backgroundColor: COLOR.theme }
    }
  }
)

const tabHome = StackNavigator(
  {
    Home: { screen: components.Home },
   
  },
  {
    navigationOptions: {
      headerTintColor: COLOR.textLightNormal,
      headerStyle: { backgroundColor: COLOR.theme },
      tabBarIcon: ({ focused, tintColor }) => (
        <Image
          source={focused ? require('./image/one_selected.png') : require('./image/one.png')}
          style={{ width: 25, height: 25 }}
        />
      ),
      title: '首页'
    }
  }
)

const tabFind = StackNavigator(
  {
    Find: { screen: components.Find },
    FindSelectLike : {screen : components.FindSelectLike}
  },
  {
    navigationOptions: {
      headerTintColor: COLOR.textLightNormal,
      headerStyle: { backgroundColor: COLOR.theme },
      tabBarIcon: ({ focused, tintColor }) => (
        <Image
          source={focused ? require('./image/one_selected.png') : require('./image/one.png')}
          style={{ width: 25, height: 25 }}
        />
      ),
      title: '发现'
    }
  }
)

const tabPictures = StackNavigator(
  {
    Pictures: { screen: components.Pictures },
 
  },
  {
    navigationOptions: {
      headerTintColor: COLOR.textLightNormal,
      headerStyle: { backgroundColor: COLOR.theme },
      tabBarIcon: ({ focused, tintColor }) => (
        <Image
          source={focused ? require('./image/one_selected.png') : require('./image/one.png')}
          style={{ width: 25, height: 25 }}
        />
      ),
      title: '拍照'
    }
  }
)
const tabMe = StackNavigator(
  {
    Me: { screen: components.Me},
 
  },
  {
    navigationOptions: {
      headerTintColor: COLOR.textLightNormal,
      headerStyle: { backgroundColor: COLOR.theme },
      tabBarIcon: ({ focused, tintColor }) => (
        <Image
          source={focused ? require('./image/one_selected.png') : require('./image/one.png')}
          style={{ width: 25, height: 25 }}
        />
      ),
      title: '拍照'
    }
  }
)
const tabDynamics = StackNavigator(
  {
    Dynamics: { screen: components.Dynamics},
 
  },
  {
    navigationOptions: {
      headerTintColor: COLOR.textLightNormal,
      headerStyle: { backgroundColor: COLOR.theme },
      tabBarIcon: ({ focused, tintColor }) => (
        <Image
          source={focused ? require('./image/one_selected.png') : require('./image/one.png')}
          style={{ width: 25, height: 25 }}
        />
      ),
      title: '拍照'
    }
  }
)

const tab = TabNavigator(
  {
    TabHome: { screen: tabHome },
    TabFind: { screen: tabFind },
    TabPictures: { screen: tabPictures },
    TabDynamics: { screen: tabDynamics },
    TabMe: { screen: tabMe }
  },
  {
    tabBarPosition: 'bottom',
    lazy: true,
    tabBarOptions: {
      activeTintColor: COLOR.theme,
      activeBackgroundColor: COLOR.backgroundLighter,
      inactiveTintColor: COLOR.textEmpha,
      inactiveBackgroundColor: COLOR.backgroundDarker,
      showIcon: true,
      showLabel: true,
      style: { backgroundColor: COLOR.backgroundDarker },
      tabStyle: { paddingTop: 2, paddingBottom: 0 },
      labelStyle: { fontSize: 12, marginTop: 0, marginBottom: 5 }
    },
    headerMode: 'none'
  }
)

export const AppNavigator = StackNavigator(
  {
    Bootstrap: { screen: components.Bootstrap },

    Login: { screen: login },

    Tab: { screen: tab }
  },
  {
    initialRouteName: 'Bootstrap',
    headerMode: 'none',
    navigationOptions: {
      gesturesEnabled: false
    }
  }
)

export function navToBootstrap(navigation, { isReset = false } = {}) {
  navigation.navigate('Bootstrap', { isReset })
}

export function navToTab(navigation) {
  
  navigation.navigate('Tab')
}

// export function navToAlbum(navigation, { files, currentIndex = 0 }) {
//   navigation.navigate('Album', { files, currentIndex })
// }

// export function navToPlayer(navigation, { file, autoPlay }) {
//   navigation.navigate('Player', { file, autoPlay })
// }
